﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/LOSSite.Master" Inherits="System.Web.Mvc.ViewPage<DataAccessLayer.Models.Application>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="MenuList" runat="server">
    <% Html.RenderPartial("MenuList", Session["LoggedUser"]); %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Greeting" runat="server">
    <% Html.RenderPartial("Greeting", Session["LoggedUser"]); %>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="Content" runat="server">
    <form id="form1" runat="server">
    <script src="<%= Url.Content("~/Scripts/MicrosoftAjax.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.js") %>" type="text/javascript"></script>
    <script src="<%= Url.Content("~/Scripts/MicrosoftMvcValidation.js") %>" type="text/javascript"></script>

    <h2>Application Summary</h2>
    
    <table>
        <tr>
            <td>Customer Name</td>
            <td><%: Model.Customer.Name %></td>
        </tr>
        <tr>
            <td>ID Number</td>
            <td><%: Model.Customer.IDNumber %></td>
        </tr>
        <tr>
            <td>DOB</td>
            <td><%: Model.Customer.DOB %></td>
        </tr>
        <tr>
            <td colspan="2">
                <%: Html.ActionLink("Edit", "Edit", "Applicant", new { customerId = Model.CustomerId }, null)%>
            </td>
        </tr>
    </table>

    <h3>Facilities</h3>
    <table>
        <tr>
            <th>Facility Id</th>
            <th>Proposed Limit</th>
            <th>Interest</th>
            <th>Repayment Amount</th>
            <th>Repayment Unit</th>
            <th>Repayment Period</th>
            <th>Tenor Unit</th>
            <th>Tenor Period</th>
        </tr>
        
        <% foreach (var item in Model.Facilities) { %> 
            <tr>
                <td>
                    <% if (item is DataAccessLayer.Models.FacilityHousingLoan)
                           Html.ActionLink(item.FacilityId.ToString(), "Index", "FacilityHousingLoan");
                       else if (item is DataAccessLayer.Models.FacilityOverDraft)
                           Html.ActionLink(item.FacilityId.ToString(), "Index", "FacilityOverDraft");
                       else if (item is DataAccessLayer.Models.FacilityTermLoan)
                           Html.ActionLink(item.FacilityId.ToString(), "Index", "FacilityTermLoan");
                    %>
                </td>
                <td>
                    <%: item.LimitAmount %>
                </td>
                <td>
                    <%: item.Interest.Percent %>
                </td>
                <td>
                    <%: item.RepaymentAmount %>
                </td>
                <td>
                    <%: item.RepaymentUnit %>
                </td>
                <td>
                    <%: item.RepaymentPeriod %>
                </td>
                <td>
                    <%: item.TenorUnit %>
                </td>
                <td>
                    <%: item.TenorPeriod %>
                </td>
            </tr>
            <% } %>
    </table>

    <h3>Securities</h3>
    
    <% foreach (var item in Model.Securities) { %> 
        <% if(item is DataAccessLayer.Models.Mortgage) { %>
            <table>
                <tr>
                    <th>Mortgage Id</th>
                    <th>Mortgagor Name</th>
                </tr>
        
                <tr>
                    <td>
                        <%: Html.ActionLink(item.SecurityId.ToString(), "initDisplay", "Mortgage") %>
                    </td>
                    <td>
                        <%: item.Application.Customer.Name %>
                    </td>
                </tr>
            </table>
        <% } %>
           
           <% else if (item is DataAccessLayer.Models.FixedDeposit) {%>
            <table>
                <tr>
                    <th>Fixed Deposit Id</th>
                </tr>
                <tr>
                    <td>
                        <%: Html.ActionLink(item.SecurityId.ToString(), "Index", "FixedDeposit") %>
                    </td>
                    <td></td>
                </tr>
            </table>
            <% } %>

            <% else if (item is DataAccessLayer.Models.PersonalGuarantee) {%>
            <table>
                <tr>
                    <th>Personal Guarantee Id</th>
                    <th>Guarantor Name</th>
                </tr>
                <tr>
                    <td>
                        <%: Html.ActionLink(item.SecurityId.ToString(), "initDisplay", "PersonalGuarantee") %>
                    </td>
                    <td>
                        <%: Model.Customer.Name %>
                    </td>
                </tr>
            </table>
            <% } %>
        <% } %>
    </form>
</asp:Content>
